<!DOCTYPE html><html><head><title>Ext.data.writer.Writer | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
<style type="text/css">.head-band { display: none; }
.header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
.doc-tab .members .member a.more { background-color: #efefef; }
</style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
</head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
<a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">

    req = {
        liveURL: '.',
        standAloneMode: true,
        origDocClass: 'Ext.data.writer.Writer',
        docClass: 'Ext.data.writer.Writer',
        docReq: 'Ext.data.writer.Writer',
        version: '4.0',
        baseURL: '.',
        baseDocURL: '.',
        baseProdURL: '.'
    };

    clsInfo = {};



</script>

<script type="text/javascript" src="../search.js"></script>
<!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
<script type="text/javascript" src="../class_tree.js"></script>
<script type="text/javascript" src="../class_doc.js"></script>
<script type="text/javascript">
    req.source = 'Writer.html#Ext-data.writer.Writer';
    clsInfo = {"methods":["Writer","getRecordData","write"],"cfgs":["nameProperty","writeAllFields"],"properties":[],"events":[],"subclasses":["Ext.data.writer.Json","Ext.data.writer.Xml"]};
    Ext.onReady(function() {
        Ext.create('Docs.classPanel');
    });
</script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/Writer.html#Ext-data.writer.Writer" target="_blank">Ext.data.writer.Writer</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>Base Writer class used by most subclasses of <a href="Ext.data.proxy.Server.html" rel="Ext.data.proxy.Server" class="docClass">Ext.data.proxy.Server</a>. This class is
responsible for taking a set of <a href="Ext.data.Operation.html" rel="Ext.data.Operation" class="docClass">Ext.data.Operation</a> objects and a <a href="Ext.data.Request.html" rel="Ext.data.Request" class="docClass">Ext.data.Request</a>
object and modifying that request based on the Operations.</p>




<p>For example a <a href="Ext.data.writer.Json.html" rel="Ext.data.writer.Json" class="docClass">Ext.data.writer.Json</a> would format the Operations and their <a href="Ext.data.Model.html" rel="Ext.data.Model" class="docClass">Ext.data.Model</a> 
instances based on the config options passed to the JsonWriter's constructor.</p>




<p>Writers are not needed for any kind of local storage - whether via a
<a href="Ext.data.proxy.WebStorage.html" rel="Ext.data.proxy.WebStorage" class="docClass">Web Storage proxy</a> (see <a href="Ext.data.proxy.LocalStorage.html" rel="Ext.data.proxy.LocalStorage" class="docClass">localStorage</a>
and <a href="Ext.data.proxy.SessionStorage.html" rel="Ext.data.proxy.SessionStorage" class="docClass">sessionStorage</a>) or just in memory via a
<a href="Ext.data.proxy.Memory.html" rel="Ext.data.proxy.Memory" class="docClass">MemoryProxy</a>.</p>

<div class="members"><div class="m-cfgs"><div class="definedBy">Defined By</div><a name="configs"></a><h3 class="cfg p">Config Options</h3><h4 class="cfgGroup">Other Configs</h4><div id="config-nameProperty" class="member f ni"><a href="Ext.data.writer.Writer.html#config-nameProperty" rel="config-nameProperty" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.writer.Writer.html" class="definedIn docClass">Ext.data.writer.Writer</a><br/><a href="../source/Writer.html#Ext-data.writer.Writer-cfg-nameProperty" class="viewSource">view source</a></div><a name="nameProperty"></a><a name="config-nameProperty"></a><a href="Ext.data.writer.Writer.html#" rel="config-nameProperty" class="cls expand">nameProperty</a><span> : String</span></div><div class="description"><div class="short">This property is used to read the key for each value that will be sent to the server.
For example:

Ext.define('Perso...</div><div class="long"><p>This property is used to read the key for each value that will be sent to the server.
For example:</p>

<pre><code>Ext.define('Person', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'first',
        mapping: 'firstName'
    }, {
        name: 'last',
        mapping: 'lastName'
    }, {
        name: 'age'
    }]
});
new Ext.data.writer.Writer({
    writeAllFields: true,
    nameProperty: 'mapping'
});

// This will be sent to the server
{
    firstName: 'first name value',
    lastName: 'last name value',
    age: 1
}

</code></pre>


<p>Defaults to <tt>name</tt>. If the value is not present, the field name will always be used.</p>
</div></div></div><div id="config-writeAllFields" class="member ni"><a href="Ext.data.writer.Writer.html#config-writeAllFields" rel="config-writeAllFields" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.writer.Writer.html" class="definedIn docClass">Ext.data.writer.Writer</a><br/><a href="../source/Writer.html#Ext-data.writer.Writer-cfg-writeAllFields" class="viewSource">view source</a></div><a name="writeAllFields"></a><a name="config-writeAllFields"></a><a href="Ext.data.writer.Writer.html#" rel="config-writeAllFields" class="cls expand">writeAllFields</a><span> : Boolean</span></div><div class="description"><div class="short">True to write all fields from the record to the server. If set to false it
will only send the fields that were modifi...</div><div class="long"><p>True to write all fields from the record to the server. If set to false it
will only send the fields that were modified. Defaults to <tt>true</tt>. Note that any fields that have
<a href="Ext.data.Field.html#persist" rel="Ext.data.Field#persist" class="docClass">Ext.data.Field.persist</a> set to false will still be ignored.</p>
</div></div></div></div><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-Writer" class="member f ni"><a href="Ext.data.writer.Writer.html#method-Writer" rel="method-Writer" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.writer.Writer.html" class="definedIn docClass">Ext.data.writer.Writer</a><br/><a href="../source/Writer.html#Ext-data.writer.Writer-method-constructor" class="viewSource">view source</a></div><a name="Writer"></a><a name="method-Writer"></a><a href="Ext.data.writer.Writer.html#" rel="method-Writer" class="cls expand">Writer</a>(
<span class="pre">Object config</span>)
 : void</div><div class="description"><div class="short"><p>&nbsp;</p></div><div class="long">
<h3 class="pa">Parameters</h3><ul><li><span class="pre">config</span> : Object<div class="sub-desc"><p>Optional config object</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">void</span>&nbsp; &nbsp;
</li></ul></div></div></div><div id="method-getRecordData" class="member ni"><a href="Ext.data.writer.Writer.html#method-getRecordData" rel="method-getRecordData" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.writer.Writer.html" class="definedIn docClass">Ext.data.writer.Writer</a><br/><a href="../source/Writer.html#Ext-data.writer.Writer-method-getRecordData" class="viewSource">view source</a></div><a name="getRecordData"></a><a name="method-getRecordData"></a><a href="Ext.data.writer.Writer.html#" rel="method-getRecordData" class="cls expand">getRecordData</a>(
<span class="pre">Object record</span>)
 : Object</div><div class="description"><div class="short">Formats the data for each record before sending it to the server. This
method should be overridden to format the data...</div><div class="long"><p>Formats the data for each record before sending it to the server. This
method should be overridden to format the data in a way that differs from the default.</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">record</span> : Object<div class="sub-desc"><p>The record that we are writing to the server.</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Object</span>&nbsp; &nbsp;<p>An object literal of name/value keys to be written to the server.
By default this method returns the data property on the record.</p>
</li></ul></div></div></div><div id="method-write" class="member ni"><a href="Ext.data.writer.Writer.html#method-write" rel="method-write" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.data.writer.Writer.html" class="definedIn docClass">Ext.data.writer.Writer</a><br/><a href="../source/Writer.html#Ext-data.writer.Writer-method-write" class="viewSource">view source</a></div><a name="write"></a><a name="method-write"></a><a href="Ext.data.writer.Writer.html#" rel="method-write" class="cls expand">write</a>(
<span class="pre">Ext.data.Request request</span>)
 : Ext.data.Request</div><div class="description"><div class="short"><p>Prepares a Proxy's <a href="Ext.data.Request.html" rel="Ext.data.Request" class="docClass">Ext.data.Request</a> object</p>
</div><div class="long"><p>Prepares a Proxy's <a href="Ext.data.Request.html" rel="Ext.data.Request" class="docClass">Ext.data.Request</a> object</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">request</span> : Ext.data.Request<div class="sub-desc"><p>The request object</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Ext.data.Request</span>&nbsp; &nbsp;<p>The modified request object</p>
</li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>